import Vue from 'vue'
import App from './App'
import {
	http
} from './api/request.js'
Vue.config.productionTip = false
import cuCustom from './conpoments/cu-custom.vue'
import loading from './conpoments/loading.vue'
import prompt from './conpoments/prompt.vue'
Vue.component('cu-custom', cuCustom)
Vue.component('loading',loading)
Vue.component('Prompt',prompt)
Vue.mixin({
	data() {
		return {
			loadingflag:false,
			authSwitch:false
		}
	},
	methods: {
		setTabBarIndex(index) {
			if (
				typeof this.$mp.page.getTabBar === 'function' &&
				this.$mp.page.getTabBar()
			) {
				this.$mp.page.getTabBar().setData({
					selected: index,
				})
			}
		},
		//检测是否有登录
		detectionState(){
			let token=uni.getStorageSync('userInfo').token || ''
			console.log(token)
			if(!token){
				uni.showToast({
					title: '未登录',
					duration: 1500,
					icon:'none'
				});
				setTimeout(()=>{
					uni.switchTab({
						 url: '/pages/my/my'
					});
				},1500)
				return false
			}
			return true
		},
		AuthState(my=false){
			let token=uni.getStorageSync('userInfo').token || ''
			
			if(!token){
				this.authSwitch=true
				return  false
			}else{
				return true
			}
		}
	},
	onShareAppMessage() {}, //所有页面混入一个分享的方法
})
App.mpType = 'app'
Vue.prototype.$http = http
Vue.prototype.$authSwitch=false

const app = new Vue({
	...App,
})
app.$mount()
